package com.king.armips.android.dialog;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;

import com.king.armips.android.R;
import com.king.armips.android.utils.ScreenUtils;

public class FileOptionsPop extends PopupWindow {

    private Context mContext;
    private ListView lvOptions;

    public FileOptionsPop(Context context) {
        super();
        mContext = context;
        setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        setWidth((int) (ScreenUtils.screenWidth * 0.26f));
        setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
        setOutsideTouchable(true);
        setFocusable(true);
        View rootView = LayoutInflater.from(context).inflate(R.layout.pop_file_options, null);
        setContentView(rootView);
        initView(rootView);

    }

    public void setOnItemClickListener(AdapterView.OnItemClickListener listener){
        lvOptions.setOnItemClickListener(listener);
    }

    private void initView(View rootView) {
        lvOptions = rootView.findViewById(R.id.lv_options);

        lvOptions.setAdapter(new ArrayAdapter<>(mContext, R.layout.list_item_option, new String[]{
                mContext.getString(R.string.rename),
                mContext.getString(R.string.export),
                mContext.getString(R.string.delete)
        }));
        lvOptions.setDivider(null);

    }




}
